/*0Ru6E3LSPQP+OhJ6c9hQMe3stOHl2M7nam+My2bzHHpUAuRtkVJ/yW5lzN0/3+Qg*/
/*
 * @Author: hufei 
 * @PageInfo: 自定义的上传组件, 原因是钉耙中的 Upload 组件不能实现上传失败后的重新上传和上传过程中的删除中断request的功能
 * @Date: 2019-02-25 13:39:16 
 * @Last Modified by: yangls7
 * @Last Modified time: 2019-08-19 20:52:48
 */
import React, { Component } from 'react';

export default class SCMUpload extends Component {
	inputChange = (e) => {
		let file = e.target.files[0];
		if (file) {
			// 生成一个uid
			file.uid = 'upload-' + new Date().getTime();
			this.props.uploadRequest(file, false);
			e.target.value = ''; // 解决input type=file 两次上传选取同一个文件不触发onchange事件
		}
	};

	selectFile = () => {
		let input = this.refs.file;
		input.click();
	};

	render() {
		let { accept = '' } = this.props;
		return (
			<div onClick={this.selectFile}>
				<input
					fieldid="File_Input"
					type="file"
					ref="file"
					style={{ display: 'none' }}
					accept={accept}
					onChange={this.inputChange}
				/>
				{this.props.children}
			</div>
		);
	}
}

/*0Ru6E3LSPQP+OhJ6c9hQMe3stOHl2M7nam+My2bzHHpUAuRtkVJ/yW5lzN0/3+Qg*/